package svc

import (
	"api/internal/config"
	"api/internal/middleware"
	"course_srv/courseclient"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
	"user_srv/userclient"
)

type ServiceContext struct {
	Config              config.Config
	UserLoginMiddleware rest.Middleware
	UserSrv             userclient.User
	CourseSrv           courseclient.Course
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:              c,
		UserLoginMiddleware: middleware.NewUserLoginMiddleware().Handle,
		UserSrv:             userclient.NewUser(zrpc.MustNewClient(c.UserSrv)),
		CourseSrv:           courseclient.NewCourse(zrpc.MustNewClient(c.CourseSrv)),
	}
}
